<?php
	require_once(BASE_FRAMEWORK . '/Thumb.class.php');

    class DirThumb
    {
    	var $thumb;
        var $debug = true;
        var $error = true;

        function DirThumb($debug = false)
        {
        	$this->debug = $debug;
        	$this->thumb = new Thumb($debug);
            $this->thumb->upload = false;
        }

        function setThumb($thumb)
        {
		    $this->thumb->setThumb($thumb);
        }

        function setDebug($dbg)
        {
		    $this->thumb->debug = $dbg;
        }

        function setDir($path)
        {
		    $this->thumb->path_original = $path;
        }

        function setRenameOriginal($rename)
        {
		    $this->thumb->rename_original = $rename;
        }

        function setUpload($upload)
        {
		    $this->thumb->upload = $upload;
        }

        function setRandomName($rand)
        {
		    $this->thumb->random_name = $rand;
        }

        function Crear()
        {
	        $d = dir($this->thumb->root.$this->thumb->path_original);
	        while($imagen = $d->read())
	        {
	            clearstatcache();
	            if ($imagen == '.' || $imagen == '..')
	            {
	                continue;
	            }

	            $foto['name']     = $imagen;
	            $foto['size']     = @filesize($this->thumb->root . $this->thumb->path_original . "/" . $imagen);
	            $foto['tmp_name'] = $this->thumb->root . $this->thumb->path_original . "/" . $imagen;

	            $thumbnail    = $this->thumb->Crear($foto);

	            if ($this->error && $this->thumb->error)
	            {
	                Debug::Mostrar($this->thumb->error());
	            }
	        }
	        $d->close();
        }
    }

?>